package com.googlecode.bip.entity.impl;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.googlecode.bip.entity.IQuestion;
import com.googlecode.bip.entity.IUser;
import com.googlecode.bip.entity.IUserIgnoreQuestion;

/**
 * Default implementation of {@link IUserIgnoreQuestion}
 */
public class UserIgnoreQuestion
    implements Serializable, IUserIgnoreQuestion
{
    private static final long serialVersionUID = 1L;

    private int iduser;     //key
    private int idquestion; //key

    /**
     * Create a NOT initialized UserIgnoreQuestion
     */
    public UserIgnoreQuestion()
    {
        //empty
    }

    /**
     * Create an UserIgnoreQuestion
     *
     * @param iuser     {@link IUser} to use to set iduser
     * @param iquestion {@link IQuestion} to use to set idquestion
     */
    public UserIgnoreQuestion( final IUser iuser, final IQuestion iquestion )
    {
        this.iduser     = iuser.getIdUser();
        this.idquestion = iquestion.getIdQuestion();
    }

    /**
     * Create an UserIgnoreQuestion
     *
     * @param iduser     value to use to set iduser
     * @param idquestion value to use to set idquestion
     */
    public UserIgnoreQuestion( final int iduser, final int idquestion )
    {
        this.iduser     = iduser;
        this.idquestion = idquestion;
    }

    /**
     * Create a shadow copy of giving UserIgnoreQuestion
     *
     * @param o UserIgnoreQuestion to clone
     */
    public UserIgnoreQuestion( final UserIgnoreQuestion o )
    {
        this.iduser     = o.iduser;
        this.idquestion = o.idquestion;
    }

    /**
     *
     * @param rSet
     * @return
     * @throws SQLException
     */
    public IUserIgnoreQuestion set( final ResultSet rSet ) throws SQLException
    {
        this.iduser      = rSet.getInt( "iduser" );
        this.idquestion  = rSet.getInt( "idquestion" );

        return this;
    }

    @Override
    public int getIdUser()
    {
        return this.iduser;
    }

    @Override
    public void setIdUser( final int iduser )
    {
        this.iduser = iduser;
    }

    @Override
    public int getIdQuestion()
    {
        return this.idquestion;
    }

    @Override
    public void setIdQuestion( final int idquestion )
    {
        this.idquestion = idquestion;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
        return "UserIgnoreQuestion [iduser=" + iduser + ", idquestion="
                + idquestion + "]";
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + idquestion;
        result = prime * result + iduser;
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals( Object obj )
    {
        if( this == obj ) {
            return true;
        }
        if( obj == null ) {
            return false;
        }
        if( !(obj instanceof UserIgnoreQuestion) ) {
            return false;
        }
        UserIgnoreQuestion other = (UserIgnoreQuestion)obj;
        if( idquestion != other.idquestion ) {
            return false;
        }
        if( iduser != other.iduser ) {
            return false;
        }
        return true;
    }
}
